<template>
  <div class="chat-messages">
    <!-- iOS状态栏 -->
    <div class="status-bar">
      <div class="status-bg">
        <div class="notch">
          <img src="@/assets/images/chat-ui/notch-black.svg" alt="notch" />
        </div>
      </div>
      <div class="status-right">
        <div class="battery">
          <div class="battery-border"></div>
          <div class="battery-tip"></div>
          <div class="battery-fill"></div>
        </div>
        <div class="wifi">
          <div class="wifi-bar wifi-1"></div>
          <div class="wifi-bar wifi-2"></div>
          <div class="wifi-bar wifi-3"></div>
        </div>
        <div class="signal">
          <div class="signal-bar signal-1"></div>
          <div class="signal-bar signal-2"></div>
          <div class="signal-bar signal-3"></div>
          <div class="signal-bar signal-4"></div>
        </div>
      </div>
      <div class="status-left">
        <div class="time">9:41</div>
      </div>
    </div>

    <!-- 页面头部 -->
    <div class="page-header">
      <div class="back-btn">Back</div>
      <div class="title">Messages</div>
      <div class="filter-btn">Filter</div>
    </div>

    <!-- 聊天消息区域 -->
    <div class="messages-container">
      <!-- 接收消息1 -->
      <div class="message-item receive">
        <div class="message-bubble">
          <div class="message-text">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec fringilla quam eu faci lisis mollis.
          </div>
        </div>
      </div>

      <!-- 发送消息1 -->
      <div class="message-item send">
        <div class="message-bubble">
          <div class="message-text">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit.
          </div>
        </div>
      </div>

      <!-- 发送消息2 -->
      <div class="message-item send">
        <div class="message-bubble">
          <div class="message-text">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit.
          </div>
        </div>
      </div>

      <!-- 接收消息2 -->
      <div class="message-item receive">
        <div class="message-bubble">
          <div class="message-text">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec fringilla quam eu faci lisis mollis.
          </div>
        </div>
      </div>
    </div>

    <!-- 输入框区域 -->
    <div class="input-container">
      <div class="input-wrapper">
        <input 
          v-model="theMessageText" 
          type="text" 
          placeholder="Message here..." 
          class="message-input"
          @keyup.enter="onSendMessage"
        />
        <div class="send-btn" @click="onSendMessage">
          <div class="send-icon-bg">
            <img src="@/assets/images/chat-ui/send-icon.svg" alt="send" class="send-icon" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { ref } from 'vue'

// 消息输入 start
const theMessageText = ref('')

const onSendMessage = () => {
  if (theMessageText.value.trim()) {
    console.log('发送消息:', theMessageText.value)
    theMessageText.value = ''
  }
}
// 消息输入 end
</script>

<style lang="scss" scoped>
.chat-messages {
  width: 375px;
  height: 812px;
  background: #FFFFFF;
  position: relative;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  .status-bar {
    width: 375px;
    height: 44px;
    position: relative;
    background: #FFFFFF;
    
    .status-bg {
      position: absolute;
      top: -2px;
      left: 0;
      width: 375px;
      height: 46px;
      
      .notch {
        position: absolute;
        top: 0;
        left: 78px;
        width: 219px;
        height: 30px;
        
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
    
    .status-right {
      position: absolute;
      top: 17.33px;
      right: 14.67px;
      display: flex;
      align-items: center;
      gap: 5px;
      
      .battery {
        position: relative;
        width: 24.33px;
        height: 11.33px;
        
        .battery-border {
          position: absolute;
          top: 0;
          left: 0;
          width: 22px;
          height: 11.33px;
          border: 1px solid #000000;
          border-radius: 2.67px;
          opacity: 0.35;
        }
        
        .battery-tip {
          position: absolute;
          top: 3.67px;
          right: 0;
          width: 1.33px;
          height: 4px;
          background: #000000;
          border-radius: 0 1px 1px 0;
          opacity: 0.4;
        }
        
        .battery-fill {
          position: absolute;
          top: 2px;
          left: 2px;
          width: 18px;
          height: 7.33px;
          background: #000000;
          border-radius: 1.33px;
        }
      }
      
      .wifi {
        display: flex;
        align-items: flex-end;
        gap: 2px;
        
        .wifi-bar {
          background: #000000;
          border-radius: 1px;
          
          &.wifi-1 {
            width: 3px;
            height: 3px;
          }
          
          &.wifi-2 {
            width: 3px;
            height: 5px;
          }
          
          &.wifi-3 {
            width: 3px;
            height: 7px;
          }
        }
      }
      
      .signal {
        display: flex;
        align-items: flex-end;
        gap: 2px;
        
        .signal-bar {
          background: #000000;
          border-radius: 1px;
          width: 3px;
          
          &.signal-1 {
            height: 4px;
          }
          
          &.signal-2 {
            height: 6px;
          }
          
          &.signal-3 {
            height: 8.33px;
          }
          
          &.signal-4 {
            height: 10.67px;
          }
        }
      }
    }
    
    .status-left {
      position: absolute;
      top: 17.17px;
      left: 33.45px;
      
      .time {
        font-size: 14px;
        font-weight: 600;
        color: #000000;
        line-height: 11.09px;
      }
    }
  }
  
  .page-header {
    position: absolute;
    top: 60px;
    left: 16px;
    width: 343px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    
    .back-btn {
      font-family: Inter, sans-serif;
      font-size: 16px;
      font-weight: 500;
      color: #5DB075;
      line-height: 19px;
      cursor: pointer;
      
      &:hover {
        opacity: 0.8;
      }
    }
    
    .title {
      font-family: Inter, sans-serif;
      font-size: 30px;
      font-weight: 600;
      color: #000000;
      line-height: 36px;
      text-align: center;
    }
    
    .filter-btn {
      font-family: Inter, sans-serif;
      font-size: 16px;
      font-weight: 500;
      color: #5DB075;
      line-height: 19px;
      cursor: pointer;
      
      &:hover {
        opacity: 0.8;
      }
    }
  }
  
  .messages-container {
    position: absolute;
    top: 128px;
    left: 0;
    right: 0;
    bottom: 66px;
    padding: 0 16px;
    overflow-y: auto;
    
    .message-item {
      margin-bottom: 16px;
      display: flex;
      
      &.receive {
        justify-content: flex-start;
        
        .message-bubble {
          background: #F6F6F6;
          border: 1px solid #E8E8E8;
          border-radius: 20px 20px 20px 4px;
          max-width: 235px;
          
          .message-text {
            font-family: Inter, sans-serif;
            font-size: 14px;
            font-weight: 400;
            color: #000000;
            line-height: 17px;
            padding: 15px 16px;
          }
        }
      }
      
      &.send {
        justify-content: flex-end;
        
        .message-bubble {
          background: #5DB075;
          border-radius: 20px 20px 4px 20px;
          max-width: 235px;
          
          .message-text {
            font-family: Inter, sans-serif;
            font-size: 14px;
            font-weight: 400;
            color: #FFFFFF;
            line-height: 17px;
            padding: 15px 16px;
          }
        }
      }
    }
  }
  
  .input-container {
    position: absolute;
    bottom: 16px;
    left: 14px;
    width: 343px;
    height: 50px;
    
    .input-wrapper {
      position: relative;
      width: 100%;
      height: 100%;
      background: #F6F6F6;
      border: 1px solid #E8E8E8;
      border-radius: 100px;
      display: flex;
      align-items: center;
      
      .message-input {
        flex: 1;
        border: none;
        background: transparent;
        outline: none;
        padding: 16px;
        font-family: Inter, sans-serif;
        font-size: 16px;
        font-weight: 500;
        color: #000000;
        line-height: 19px;
        
        &::placeholder {
          color: #BDBDBD;
        }
      }
      
      .send-btn {
        position: absolute;
        right: 8px;
        width: 34px;
        height: 34px;
        cursor: pointer;
        
        .send-icon-bg {
          width: 100%;
          height: 100%;
          background: #5DB075;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          transition: all 0.3s ease;
          
          &:hover {
            background: #4A9A63;
            transform: scale(1.05);
          }
          
          .send-icon {
            width: 10px;
            height: 14px;
            filter: brightness(0) invert(1);
          }
        }
      }
    }
  }
}

// 响应式适配
@media (max-width: 375px) {
  .chat-messages {
    width: 100vw;
    height: 100vh;
  }
}
</style>